package com.seeyon.apps.kk.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.seeyon.apps.kk.manager.AssetCardSyncManagerImpl;
import com.seeyon.apps.kk.manager.OrgSyncManagerImpl;
import com.seeyon.apps.kk.manager.meetingImpl.ShkkMeetingManagerImpl;
import com.seeyon.ctp.common.AppContext;

public class MeetingSyncController extends KkBaseController{
	private static final Log log = LogFactory.getLog(MeetingSyncController.class);
	private ShkkMeetingManagerImpl meetingManagerImpl = (ShkkMeetingManagerImpl) AppContext.getBean("shkkMeetingManagerImpl");
	
	public void createMeeting(HttpServletRequest request,HttpServletResponse response){
		log.info("======shkk=====会议系统创建会议   start！");
		String meetingId=request.getParameter("meetingId");
		String meetingRoomPermId=request.getParameter("meetingRoomPermId");
		String description=request.getParameter("description");
		boolean result=meetingManagerImpl.createNewMeeting(meetingId,meetingRoomPermId,description);
		try {
			response.getWriter().print(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		log.info("======shkk=====会议系统创建会议   end！");
	}
	
	public void updateMeeting(HttpServletRequest request,HttpServletResponse response){
		log.info("======shkk=====会议系统修改会议   start！");
		String meetingId=request.getParameter("meetingId");
		String meetingRoomPermId=request.getParameter("meetingRoomPermId");
		String description=request.getParameter("description");
		boolean result=meetingManagerImpl.updateMeeting(meetingId,meetingRoomPermId,description);
		try {
			response.getWriter().print(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		log.info("======shkk=====会议系统修改会议   end！");
	}
	
	/**
	 * 1.如果不与天目神盾做对接的会议，返回消息为0。  表示OA当中撤销与天目神盾无关、 
	 * 2.与天目神盾做对接的会议根据会议系统的返回结果来决定是否允许撤销会议  允许：1   不允许：2
	 * @param request
	 * @param response
	 */
	public void revokeMeeting(HttpServletRequest request,HttpServletResponse response){
		log.info("======shkk=====会议系统撤销会议   start！");
		String meetingId=request.getParameter("meetingId");
		int result=meetingManagerImpl.revokeMeeting(meetingId);
		try {
			response.getWriter().print(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		log.info("======shkk=====会议系统撤销会议   end！");
	}
	
	public void closeMeeting(HttpServletRequest request,HttpServletResponse response){
		log.info("======shkk=====会议系统关闭会议   start！");
		String meetingId=request.getParameter("meetingId");
		boolean result=meetingManagerImpl.closeMeeting(meetingId);
		try {
			response.getWriter().print(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		log.info("======shkk=====会议系统关闭会议   end！");
	}
	
	public void meetingIsCreateOrUpdate(HttpServletRequest request,HttpServletResponse response){
		log.info("======shkk=====判断会议是新建还是修改   start！");
		String meetingId=request.getParameter("meetingId");
		int result=meetingManagerImpl.meetingIsCreateOrUpdate(meetingId);
		try {
			response.getWriter().print(result);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		log.info("======shkk=====判断会议是新建还是修改   end！");
	}
	
}
